<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //d = parseInt(总秒数/60/60/24);    计算天数、
        //h = parseInt(总秒数/60/60%24);    计算小时
        //m = parseInt(总秒数/60 %60);      计算分数
        //s = parseInt(总秒数%60);          计算当前秒数

        function Datatime(time) {
            var gettime = +new Date();   //获取当前时间毫
            var usertime = +new Date(time);    //用户输入的时间

            //然后 用户输入时间 - 当前时间毫 =要倒计时时间毫 / 1000  转换为秒数
            var dwotime = (usertime - gettime) / 1000;

            var d = parseInt(dwotime / 60 / 60 / 24);
            var d = d < 10 ? '0' + d : d;               //三元表达式

            var h = parseInt(dwotime / 60 / 60 % 24);
            var h = h < 10 ? '0' + h : h;

            var m = parseInt(dwotime / 60 % 60);
            var m = m < 10 ? '0' + m : m;

            var s = parseInt(dwotime % 60);
            var s = s < 10 ? '0' + s : s;

            return d + '天' + h + '时' + m + '分' + s + '秒';
        }
        console.log(Datatime('2020-11-14 14:00:00'))
        console.log(Date());
    </script>
</head>

<body>

</body>

</html>